//----------------------------------------------------------------------------------------------//
//												//
//	What type of program is this?								//
//												//
//----------------------------------------------------------------------------------------------//

This program is a type of expert advisor.
It is intended only for training the built-in AI in a separate main indicator program.
The AI training utility is free and can be downloaded by you from the main product page on the MQL5 website.
After downloading, you place it in the terminal folder manually.
It must be placed in the folder where the SolarTrade Suite series experts are located.
ATTENTION: !!! Do not place it in the folder with indicators, otherwise you will not be able to run it in the strategy tester !!!
To speed up calculations, this program uses OpenCL, to run it you must have an
appropriate device - GPU or CPU with good built-in graphics.
Make sure that the device you need is selected and enabled in the terminal settings.


//----------------------------------------------------------------------------------------------//
//												//
//	What is it for?										//
//												//
//----------------------------------------------------------------------------------------------//

This utility is designed to train or retrain the neural networks contained in the AI of the corresponding indicator.
It is recommended to use it as often as possible, but not later than one or two years after the last use or when the corresponding advisors were first enabled on a previously unused
symbol , or if a long period of time has passed since the last training,
or you observe significant changes in the price behavior of the symbol used.


//----------------------------------------------------------------------------------------------//
//												//
//	Making a plan.										//
//												//
//----------------------------------------------------------------------------------------------//

This indicator uses a trainable AI to predict future price action.

The built-in AI is trainable, i.e. without prior training it has no parameters and will not run.
Therefore, the very first thing you need to do is prepare the data for training the built-in AI.
To do this, you need to make sure that historical price data for the financial instrument for which you want to use this indicator is available, following the basic steps and requirements described below.

Find the first date available in the quote history on your broker's server for the symbol of your choice - the easiest way is to open a window in the terminal with the symbol of your choice, switch to the monthly time frame and select the maximum scale,
then wait for all available history to load from the server and
find the date of the very first candle. This technique is necessary because the built-in AI uses the price history for the last 9 years as input to make a forecast.

Not all brokers provide such a large volume of available history on their servers.
Then try temporarily switching to another broker, where there is a longer history, to
get data for training the AI there, and then
switching back to your trading broker.
For example, to train the AI, I took the quote history from
a free demo account of the broker "MetaQuotes", where, for example, for "EURUSD" there are
quotes earlier than 1990, which is ideal for our case.

We do not recommend using the built-in AI on symbols, where
the available quote history is less than 15 years.
On the other hand, the maximum history length that this program can process is 40 years.
We do not recommend exceeding this limit.
If your broker provides a deeper history, reduce the time interval in the strategy tester settings until it meets the described requirements.

The AI training utility is free and can be downloaded manually by you from
the main product page on the MQL5 website. After carefully studying the instructions for
the "AI Training Utility" program, follow these steps.

Now our plan for, for example, "EURUSD" is as follows:

- using the utility for training the built-in AI, we will launch the data acquisition stage in the strategy tester
from January 1, 2000 and ending with today's date. This must be done on a
monthly timeframe with optimization disabled and forward testing disabled using the "OHLC on M1" option.

This program uses "OpenCL" to speed up calculations, to run it you need to have an appropriate device - a GPU or CPU with good built-in graphics.
A very simple 10-year-old GPU with more than 3 gigabytes of memory is enough here.
Make sure that the device you need is selected and enabled in the terminal settings.
For an intermediate step, we need to run the AI training utility in a regular terminal window, but
not in the strategy tester. To do this, open a new window in the terminal, if it has not already been done,
with a chart of the symbol we need on any time frame:

- Run the AI training utility in this window.
Assuming that we did everything correctly in the previous steps, a comment should appear in the window where
the program is launched, indicating the stage and the current error reached in the training process. Just do nothing else and
calmly wait until the training process is completed automatically.

//----------------------------------------------------------------------------------------------//
//												//
//	How to get the input data file to train the corresponding neural networks?		//
//												//
//----------------------------------------------------------------------------------------------//

To obtain training data and, accordingly, the training itself,
You need to run this program several times in the strategy tester,
and then alternately in a regular terminal window.

There are 16 stages involved here:

- Special statistics are collected at the first two stages,
- Starting with the third stage, training data is directly prepared, where after each
pass in the strategy tester, you need to run this utility in a regular terminal window.

List of stages:

- 1) Forward_RNG,

- 2) Backward_RNG,

- 3) Forward_M1,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 4) Forward_M5,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 5) Forward_M30,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 6) Forward_H4,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 7) Forward_D1,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 8) Forward_W1,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 9) Forward_MN1,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 10) Backward_MN1,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 11) Backward_W1,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 12) Backward_D1,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 13) Backward_H4,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 14) Backward_M30,
- intermediate launch outside the strategy tester in the regular terminal window for training the built-in AI,

- 15) Backward_M5,
- intermediate launch outside the strategy tester in the regular terminal window for training built-in AI,

- 16) Backward_M1,
- Final launch outside the strategy tester in a regular terminal window to train the built-in AI.

If you are preparing the AI for the selected symbol for the first time,
or if a long period of time has passed since the last training,
or you observe significant changes in the price behavior of the symbol used,
you need to perform these steps in strict sequence from 1 to 16.

All the steps described above must be performed strictly in the described sequence, otherwise
when starting the indicator, an error will occur with a message about the need to repeat
training in the strict described sequence.

!!! ATTENTION: All work in the strategy tester must be performed only on the "MN1" timeframe, and
make sure that at least 108 candles of the "MN1" timeframe or
10 years are available from the beginning of the testing date!!! This is necessary because
the built-in AI uses approximately 9 years of price history as input to make a forecast.

For example: if the start date in the strategy tester is 2000, then
the available price history must start from 1990.
It is therefore necessary to use a monthly time frame,
as such price history will not be available on lower time frames.

Run the strategy tester with optimization DISABLED on a monthly time frame,
using the longest possible available history time range for this symbol,
at least four times more than you plan to use for optimization.

For speed, this step can be done using only "OHLC prices on M1", and
never use "open prices only", as this requires the high and low prices of each candle.
It is not recommended to use "every tick" or "real ticks" mode here,
as this will only increase the data collection time.


//----------------------------------------------------------------------------------------------//
//												//
//	How to start training AI?   								//
//												//
//----------------------------------------------------------------------------------------------//

This is only possible after receiving the input data for training from the strategy tester after the corresponding
previous steps described above.
To start the training process, after each preliminary step in the strategy tester,
you need to run this program in a normal terminal window, not in the strategy tester.


//----------------------------------------------------------------------------------------------//
//												//
//	Description of the menu options of this program.					//
//												//
//----------------------------------------------------------------------------------------------//

There are two groups of parameters:

- "Stage"

This group of parameters is valid only in the strategy tester - not in the regular window.

- "Learn"

This group of parameters is valid only outside the strategy tester - in the regular window.

group "Stage"

There is only one parameter here - "Stage" and there are 16 options:

- 1) Forward_RNG,
- 2) Backward_RNG,
- 3) Forward_M1,
- 4) Forward_M5,
- 5) Forward_M30,
- 6) Forward_H4,
- 7) Forward_D1,
- 8) Forward_W1,
- 9) Forward_MN1,
- 10) Backward_MN1,
- 11) Backward_W1,
- 12) Backward_D1,
- 13) Backward_H4,
- 14) Backward_M30,
- 15) Backward_M5,
- 16) Backward_M1

group "Learn"

1) SymbolNM: - If the symbol of the graph on which the training program is launched matches with
a training data symbol, then this field can be left blank, otherwise
enter the symbol name manually. For example: "EURUSD" or "XAUUSD" or "BTCUST" ...

2) DeviceAI: - 0 - means automatic selection of the OpenCL device, or
look in the terminal on the "tools" panel in the "experts" tab for a list of devices with
the corresponding numbers and use the one you need. This list will appear after starting the program.

3) ButtonSz: - This is the multiplication factor for the size of the STOP button object.
It can be used if the program could not automatically calculate the size correctly or
it does not suit you. For example, "2" will double the size, and "0.5" will reduce it by 2 times.

4) TextSize: - This is the multiplication factor for the size of the text of the STOP button.
It can be used if the program could not automatically calculate the size correctly or
it does not suit you. For example, "2" will double the size, and "0.5" will decrease it by half.


//----------------------------------------------------------------------------------------------//
//												//
//	Features of using this program.								//
//												//
//----------------------------------------------------------------------------------------------//

The AI training utility is free and can be downloaded manually from the main product page on the MQL5 website.
Before you start, make sure that your computer meets the minimum hardware requirements:

- 20 gigabytes of free hard disk space,
- 4 gigabytes of video card with OpenCL support,
- 16 gigabytes of RAM.

ATTENTION: - The AI parameter files for each symbol take up approximately 1 gigabyte.

Also make sure that OpenCL support is enabled in the terminal settings and the appropriate device is selected.
Check for yourself: "How many simultaneously running programs can your GPU,
CPU and RAM handle?", for example, using the "Windows Task Manager".

Depending on your computer's capabilities (CPU, GPU,
RAM, and hard drive), it may take some time to initialize the program after launch,
so don't worry if nothing appears in the startup window right away - just wait,
unless the program itself stops working.

When launched outside the strategy tester, a "STOP" button will appear in the lower right corner of the program window - it is better to use it if
you do not want to wait for automatic completion, as this gives a greater guarantee that the parameters of the trained AI will be saved on the hard drive.
And here, too, it may take some time for the program to complete after pressing the "STOP" button,
as with the launch - try not to interrupt it forcibly, but patiently wait for automatic completion.

When you launch "AI Learn Utility", in the window of the running program you will see the calculated error
of each neural network included in the general ensemble.

The error calculation and the prediction itself are made using methods of advanced mathematical, statistical analysis and machine learning, but the price of a financial instrument can be affected by other events that are not taken into account by such methods, such as political intentions, environmental events, weather conditions, etc.

All parameters are saved to the hard drive in the terminal folder "//Common//Files//SolarTradeSuite//Theia//...".
If you have a link to download ready-made parameters for the AI, then after downloading, copy them here.

Do not forget to manually backup the AI parameters to a separate folder that you created yourself.

If you do not like the previously trained AI, just find the corresponding subfolders with the names of the
corresponding indicator in the folder specified above - delete the files. After that, you can train the AI from scratch.


//----------------------------------------------------------------------------------------------//
//												//
//	Additional questions.									//
//												//
//----------------------------------------------------------------------------------------------//

The AI training utility is free and can be downloaded manually by you from the
main product page on the MQL5 website.
All instructions are available and can be downloaded manually by you from the
main product page on the MQL5 website. Please read all instructions and the
license file carefully before asking any questions.

1) Please feel free to ask questions in the discussion tab on the corresponding indicator page on the MQL5.com website.

2) Email for communication: gerasimovadam@gmail.com , tgwls2@gmail.com .